﻿<Window x:Class="DemoTransformBox.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:transformbox="clr-namespace:TransformBox;assembly=TransformBox"
        xmlns:ui="clr-namespace:DemoTransformBox.UI"
        WindowStartupLocation="CenterScreen" WindowState="Maximized" Title="Demo TransformBox">

    <Border Style="{StaticResource BorderStyle}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Border Style="{StaticResource BorderStyle}" HorizontalAlignment="Right" Panel.ZIndex="1" Grid.Row="0">
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="Select the image with the mouse. Transform the image with your mouse or buttons. Click the button to apply or cancel the transformation." FontWeight="Bold" Margin="5"/>
                    <ui:ManagementTransform x:Name="managementTransform" IsEnabled="False" SelectedPoint="ManagementTransformSelectedPoint" SelectedOperation="ManagementTransformSelectedOperation" Grid.Column="0"/>
                </StackPanel>
            </Border>

            <Border Style="{StaticResource CanvasBorderStyle}" Panel.ZIndex="0" Grid.Row="1">
                <Canvas>
                    <Image Source="Images/1.jpg" Width="396" Height="264" MouseLeftButtonUp="ImageMouseLeftButtonUp">
                        <Image.RenderTransform>
                            <MatrixTransform>
                                <MatrixTransform.Matrix>
                                    <Matrix M11="1" M12="0" M21="0" M22="1" OffsetX="0" OffsetY="0"/>
                                </MatrixTransform.Matrix>
                            </MatrixTransform>
                        </Image.RenderTransform>
                    </Image>

                    <Image Source="Images/2.jpg" Width="240" Height="160" MouseLeftButtonUp="ImageMouseLeftButtonUp">
                        <Image.RenderTransform>
                            <MatrixTransform>
                                <MatrixTransform.Matrix>
                                    <Matrix M11="1.31464195900553" M12="1.22951881629445" M21="-1.22951881629445" M22="1.31464195900553" OffsetX="340.749" OffsetY="81.44997144514"/>
                                </MatrixTransform.Matrix>
                            </MatrixTransform>
                        </Image.RenderTransform>
                    </Image>

                    <Image Source="Images/3.jpg" Width="225" Height="159" MouseLeftButtonUp="ImageMouseLeftButtonUp">
                        <Image.RenderTransform>
                            <MatrixTransform>
                                <MatrixTransform.Matrix>
                                    <Matrix M11="1.8" M12="0" M21="0" M22="1.8" OffsetX="370" OffsetY="350"/>
                                </MatrixTransform.Matrix>
                            </MatrixTransform>
                        </Image.RenderTransform>
                    </Image>

                    <transformbox:TransformBox x:Name="transformBox" Style="{StaticResource TransformBoxStyle}" Width="{Binding ActualWidth, ElementName=rootPanel}" Height="{Binding ActualHeight, ElementName=rootPanel}" />
                </Canvas>
            </Border>
        </Grid>
    </Border>

</Window>